package cn.bugstack.springframework.test;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorDemo {
    static class PrintTask implements Runnable {

        @Override
        public void run() {
            System.out.println("I am a print task.");
        }
    }

    public static void main(String[] args) {
        //定义一个线程池
        ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 0L,
                TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
        //新建一个任务提交到任务池执行，不需要执行结果
        executor.execute(new PrintTask());
    }
}
